function person(name, age) {
  this.name = name;
  this.age = age;
}

person.prototype.setName = function(name) {
  this.name = name;
}

person.prototype.sayName = function() {
  console.log('person prototype sayName', this.name);
}
person.prototype.sayAge = function() {
  console.log('person prototype sayAge', this.age);
}

function subPerson(sex) {
  this.sex = sex;
}

function subPerson2(name, age, sex) {
  person.call(this, name, age);
  this.sex = sex;
}


subPerson2.prototype = Object.create(person.prototype)
subPerson2.prototype.constructor = subPerson2;
subPerson.prototype.saySex = function() {
  return this.sex;
}

subPerson2.__proto__.print = function() {
  console.log('print')
}
console.log(subPerson2.__proto__)

// subPerson.prototype = new person('ming111', 10);
// subPerson.prototype.constructor = subPerson;
// var ming = new subPerson('male');
var ming2 = new subPerson2('kardel', 30, 'male');
// console.log(Object.getPrototypeOf(ming2))
// console.log(ming2.__proto__.constructor)
// console.log(ming2.sayName())
// console.log(subPerson.print())
// var ming = new person('ming111', 10);
// ming.constructor = subPerson;
// console.log(subPerson.__proto__)
// console.log(ming.name)
// console.log(ming.sex)
// console.log(ming.constructor)
// console.log(ming.prototype)
// console.log(person.prototype.constructor)
// console.log(person.prototype.isPrototypeOf(ming))
// console.log(subPerson.prototype.isPrototypeOf(ming))
// console.log(ming instanceof subPerson)
// console.log(ming instanceof person)
// var s = {
//   a: 1
// };
// var s1 = Object.create(s);
// console.log(s1.__proto__)

var s1 = {
  a: 2,
  b: function() {
    return () => {
      console.log(this.a)
    }
  },
  toString() {
    return ++this.a
  }
}
var c = {
  b1: 10,
  n: function() {
    console.log(this.b1)
  }
}
s1.b.call(c)
var s2 = Object.create(s1);
console.log(Object.getPrototypeOf(s2));
console.log(s2.__proto__)